import api from "../index";
import request from "../../utils/request";

/**
 * 查询群组
 * @param keyword
 * @returns {*}
 */
export function queryGroupsByKeyword(keyword) {
  const data = {
    keyword: keyword
  }
  return request({
    url: api.queryGroupsByKeyword,
    method: "post",
    data
  })
}

//userID对应的用户创建了一个群组，名称是name，信息是introduction
export function createGroup(userId, name, introduction) {
  const data = {
    userId: userId,
    name: name,
    introduction: introduction
  }
  return request({
    url: api.createGroup,
    method: "post",
    data
  })
}

export function modifyGroup(id, name, introduction) {
  const data = {
    id: id,
    groupname: name,
    introduction: introduction
  }
  return request({
    url: api.modifyGroup,
    method: "post",
    data
  })
}

export function deleteGroup(id) {
  const data = {
    id: id
  }
  return request({
    url: api.deleteGroup,
    method: "post",
    data
  })
}

//查询id对应群组下的所有答者的id和name
export function queryAnswerers(id) {
  const data = {
    id: id
  }
  return request({
    url: api.queryAnswerers,
    method: "post",
    data: data
  })
}

//从groupId对应的群组中移除answererId对应的答者
export function removeAnswerer(groupId, answererId) {
  const data = {
    groupId: groupId,
    answererId: answererId
  }
  return request({
    url: api.removeAnswerer,
    method: "post",
    data: data
  })
}

